#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fileencoding=utf-8

import os, yaml
from pyscript.core import singleton

@singleton
class Config(object):

    def __init__(self):
        self.content = dict()


    def load_config(self, configure_filename=''):

        if os.path.exists(configure_filename):
            try:
                config = yaml.safe_load(open(configure_filename, 'r'))
                self.content.update(config)
            except Exception as e:
                print e
                self.content = None
        else:
            print "configure file not exist"


    def option(self, option, default=None):
        return self.content.get(option, default) if self.content is not None else default
